home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc1_2_x / qckcmpct.sit / Quick Compacter 2.0 / stack.txt < prev   
Text File  |  1990-02-01  |  11KB  |  359 lines

  1. -- stack: in.0
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2588
  12. -- card count: 1
  13. -- first card id: 2975
  14. -- list block id: 2138
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 57504 bytes
  21. -- stack block size: 17920 bytes
  22. -- created by hypercard version: 0x01228000
  23. -- compacted by hypercard version: 0x01258000
  24. -- modified by hypercard version: 0x01258000
  25. -- opened by hypercard version: 0x01258000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. --- This is version 2.0 of Quick Compacter. It was released on Feb 1
  69. --- 1990.
  70. --- Startup script was copied from the Apple Q&A stack (version 3.2.1).
  71. --- Thanks Apple!
  72. on startup
  73.   set cursor to watch
  74.   global startups
  75.   add 1 to startups
  76.   if startups = 1 then send startup to Home
  77.   set userLevel to 5
  78.   choose browse tool
  79. end startup
  80. on OpenStack
  81.   global totsav,nmQC,f1,DQC,prefshi,shs
  82.   if the version<1.2 then
  83.     beep
  84.     answer "Sorry, you must use HyperCard version 1.2 or greater." with "OK"
  85.     go home
  86.     exit openstack
  87.   end if
  88.   set cursor to watch
  89.   hide msg
  90.   send UpdatePrefs to background
  91.   if item 9 of prefshi=false then hide menubar
  92.   if item 3 of prefshi=true then
  93.     lock screen
  94.     put TKdoTEXT(StartInfo) into cd fld StartInfo
  95.     show cd fld "StartInfo"
  96.     unlock screen with wipe right
  97.     select line 12 of cd fld "StartInfo"
  98.     repeat until the mouse is down
  99.     end repeat
  100.     lock screen
  101.     hide cd fld "StartInfo"
  102.     put empty into cd fld "StartInfo"
  103.     unlock screen with wipe left
  104.   end if
  105.   send CleanUp to background
  106.   hide tool window
  107.   hide pattern window
  108.   if cd fld "Title" is not empty and cd fld "Totsavings" is not empty then
  109.     answer "Some information was left in the Report field" with "Clear It" or "Leave It"
  110.     set cursor to watch
  111.     lock screen
  112.     if it= "Clear It" then
  113.       put empty into cd fld "Title"
  114.       put empty into cd fld "BSaved"
  115.       put empty into cd fld "PerSaved"
  116.       put 0 into cd fld "Totsavings"
  117.       put 0 into cd fld "Totsavings2"
  118.     end if
  119.     set the scroll of cd fld id 4 to 0
  120.     set the scroll of cd fld id 25 to 0
  121.     set the scroll of cd fld id 53 to 0
  122.     unlock screen
  123.   end if
  124.   put cd fld "Totsavings2" into totsav
  125.   put long name of this stack into nmQC
  126.   repeat with i=7 down to 1
  127.     delete char i of nmQC
  128.   end repeat
  129.   delete last char of nmQC
  130.   put empty into DQC
  131.   put TKpathName("Vol",nmQC) into DQC
  132.   delete last char of DQC
  133.   put "Help File" into shs
  134.   ClearScreen
  135.   UD
  136. end OpenStack
  137. on ClearScreen
  138.   set the userLevel to 5
  139.   lock screen
  140.   choose select tool
  141.   doMenu select all
  142.   doMenu clear picture
  143.   choose browse tool
  144.   put 0 into cd fld "%done"
  145.   unlock screen
  146. end ClearScreen
  147. on CloseStack
  148.   global prefshi,shs
  149.   if the visible of cd fld shs is true then send MouseDown to cd btn id 37
  150.   if the visible of cd btn id 97 is true then send MouseUp to cd btn id 97
  151.   put empty into cd fld "Hello!"
  152.   if the freesize of this stack>0 then
  153.     send CleanUp to background
  154.     if item 2 of prefshi=true then
  155.       put cd fld "Wasted" into Cb
  156.       delete char 1 of Cb
  157.       put "Attempting to compact"&&Cb&&"bytes in Quick CompacterΓäó."
  158.       domenu "Compact Stack"
  159.     end if
  160.   end if
  161.   send CleanUp to background
  162.   visual effect wipe left
  163. end CloseStack
  164.  
  165. on DoIt
  166.   global tst,totsav,nmQC,Numb,TotNumb,STKP,Multcnt,CS,prefshi
  167.   put TKpathName("Leaf",STKP) into SHRTSTKP
  168.   if the shiftkey is down and the mouse is down then exit doit
  169.   put the cantmodify of STKP into CM
  170.   if CM=true then set cantmodify of STKP to false
  171.   if the cantmodify of STKP=true then ---Checks if stack is locked
  172.     put SHRTSTKP&&"can not be opened to compact."
  173.     if item 1 of prefshi=true then
  174.       repeat with i=1 to item 10 of prefshi
  175.         beep
  176.       end repeat
  177.     end if
  178.     if item 12 of prefshi=true then
  179.       if CS="S" or CS="Q1" then
  180.         answer "That stack is locked or in use." with "OK"
  181.       else
  182.         answer "That stack is locked or in use." with "Cancel Run" or "Continue Run"
  183.         if it="Cancel Run" then put 1 into tst
  184.       end if
  185.     end if
  186.     set cursor to watch
  187.     exit Doit
  188.   end if
  189.   if the shiftkey is down and the mouse is down then exit doit
  190.   --End of most Error Checking. Stack should be compactable.
  191.   put the freesize of STKP into FTS
  192.   put the size of STKP into STS
  193.   put the number of chars of FTS into c
  194.   put FTS into Cb
  195.   if c>3 then put (char c-3 of Cb)&"," into char c-3 of Cb
  196.   set lockmessages to true
  197.   lock screen
  198.   go to stack STKP
  199.   if item 5 of prefshi=true then
  200.     unlock screen with visual effect wipe left
  201.   end if
  202.   put the diskspace into dskspace
  203.   put (STS*1.1) into aSTS
  204.   if dskspace<aSTS then
  205.     go to stack nmQC
  206.     put "Not enough disk space to compact"&&SHRTSTKP&"."
  207.     if item 1 of prefshi=true then
  208.       repeat with i=1 to item 10 of prefshi
  209.         beep
  210.       end repeat
  211.     end if
  212.     if item 12 of prefshi=true then
  213.       if CS="S" or CS="Q1" then
  214.         answer "Disk space error." with "OK"
  215.       else
  216.         answer "Disk space error." with "Cancel Run" or "Continue Run"
  217.         if it="Cancel Run" then put 1 into tst
  218.       end if
  219.     end if
  220.     set cursor to watch
  221.     if CS="MS" then wait 45 ticks
  222.     unlock screen with visual effect wipe left
  223.     set lockmessages to false
  224.     exit DoIt
  225.   end if
  226.   put the userlevel into ulstk
  227.   if ulstk<3 then
  228.     go to stack nmQC
  229.     put SHRTSTKP&&"is protected, can't be compacted."
  230.     if item 1 of prefshi=true then
  231.       repeat with i=1 to item 10 of prefshi
  232.         beep
  233.       end repeat
  234.     end if
  235.     if CS="MS" then wait 45 ticks
  236.     unlock screen with visual effect wipe left
  237.     set lockmessages to false
  238.     exit DoIt
  239.   end if
  240.   put "Attempting to compact"&&Cb&&"bytes in"&&SHRTSTKP&"."
  241.   set the cantmodify of this stack to false
  242.   choose browse tool
  243.   domenu compact stack
  244.   if CM=true then set the cantmodify of this stack to CM
  245.   if item 5 of prefshi=true then lock screen
  246.   go to stack nmQC
  247.   if item 5 of prefshi=true then
  248.     unlock screen with visual effect wipe left
  249.     lock screen
  250.   end if
  251.   set lockMessages to false
  252.   if the freesize of STKP>0 then ---last minute error checking!
  253.     put "The stack could not be correctly compacted."
  254.     if item 1 of prefshi=true then
  255.       repeat with i=1 to item 10 of prefshi
  256.         beep
  257.       end repeat
  258.     end if
  259.     if item 12 of prefshi=true then
  260.       if CS="S" or CS="Q1" then
  261.         answer "There was an unexpected error." with "OK"
  262.       else
  263.         answer "There was an unexpected error." with "Cancel Run" or "Continue"
  264.         if it="Cancel Run" then put 1 into tst
  265.       end if
  266.     end if
  267.     set cursor to watch
  268.     exit Doit
  269.   end if
  270.   add 1 to Multcnt
  271.   put "Compacted"&&CB&&"bytes in"&&SHRTSTKP&"."
  272.   if item 4 of prefshi=true then
  273.     if item 1 of prefshi=true then
  274.       repeat with i=1 to item 11 of prefshi
  275.         beep
  276.       end repeat
  277.     end if
  278.   end if
  279.   put the number of lines in cd fld "Title" into LnsRep
  280.   add 1 to LnsRep
  281.   put (FTS/STS*100) into Prs
  282.   if Prs<1 and PrsΓëá0 then put "<1" into prs else put round((FTS/STS)*100) into Prs
  283.   put Prs&&"%" into line(LnsRep) of cd fld "PerSaved"
  284.   put SHRTSTKP into line(LnsRep) of cd fld "Title"
  285.   put Cb into line(LnsRep) of cd fld "BSaved"
  286.   add FTS to totsav
  287.   put the number of chars of totsav into c
  288.   put totsav into tCb
  289.   if c>3 then put (char c-3 of tCb)&"," into char c-3 of tCb
  290.   put the number of chars of totsav into c
  291.   if c>6 then put (char c-6 of tCb)&"," into char c-6 of tCb
  292.   put tCb into cd fld "Totsavings"
  293.   put totsav into cd fld "Totsavings2"
  294.   unlock screen
  295. end Doit
  296. on RemoveIt
  297.   global itemQL,tst,CS,itemQL2
  298.   answer "Remove this stack from the Quick List?" with "OK" or "Cancel"
  299.   if it="OK" then
  300.     delete item itemQL of cd fld "QListform"
  301.     delete line itemQL-1 of cd fld "QuickList"
  302.     put 1 into itemQL2
  303.   end if
  304.   if CS="Q2" then answer "Continue compacting the Quick List?" with "Cancel Run" or "Continue Run"
  305.   if it="Cancel Run" then  put 1 into tst
  306. end RemoveIt
  307. on QcCheck
  308.   global STKP,prefshi,tst,QCErr
  309.   put empty into QCErr
  310.   put "Checking stack: "&TKpathName("Leaf",STKP)
  311.   put FileExists(STKP) into Exist
  312.   if Exist="False" then
  313.     put TKpathName("Leaf",STKP)&&"does not exist. Remove it from the Quick List."
  314.     if item 12 of prefshi=true then
  315.       answer "That stack does not exist." with "Remove It" or "Cancel Run" or "Continue Run"
  316.       if it="Cancel Run" then put 1 into tst
  317.       if it="Remove It" then
  318.         RemoveIt
  319.       end if
  320.     else
  321.       wait 180 ticks
  322.     end if
  323.     put "error" into QCErr
  324.     set cursor to watch
  325.   end if
  326. end QcCheck
  327. on OsErr err
  328.   if err > 0 then
  329.     put "Parameter error with function" into errstr
  330.   else if err is -59 then
  331.     put "Problem during rename" into errstr
  332.   else if err is -54 then
  333.     put "Attempt to open locked file for writing" into errstr
  334.   else if err is -46 then
  335.     put "Volume locked by software" into errstr
  336.   else if err is -45 then
  337.     put "File locked" into errstr
  338.   else if err is -44 then
  339.     put "Volume locked by hardware" into errstr
  340.   else if err is -43 then
  341.     put "File not found" into errstr
  342.   else if err is -37 then
  343.     put "Bad volume or file name" into errstr
  344.   else if err is -36 then
  345.     put "I/O error" into errstr
  346.   else if err is -35 then
  347.     put "No such volume" into errstr
  348.   else if err is -34 then
  349.     put "Disk is full" into errstr
  350.   else if err is -49 then
  351.     put "Sorry, File already open for writing" into errstr
  352.   else
  353.     put "Sorry, failed with error" && err into errstr
  354.   end if
  355.   put "." after errstr
  356.   answer errstr with "OK"
  357. end OsErr
  358.  
  359.